<template>
  <div id="centerRight1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span>
          <icon name="chart-line" class="text-icon"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-xl text mx-2">最新人才数据</span>
        </div>
      </div>
      <div class="d-flex jc-center body-box">
        <dv-scroll-board ref="dvScolBoard" class="dv-scr-board" :config="config" />
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      config: {
        header: ['用户名', '性别', '学历'],
        data: [
        ],
        //表格行数
        rowNum: 5,
        headerHeight: 35,
        //表头
        headerBGC: '#0f1325',
        //奇数行
        oddRowBGC: '#0f1325',
        //偶数行
        evenRowBGC: '#171c33',
        index: true,
        columnWidth: [50],
        align: ['center']
      }
    }
  },

  mounted() {
    this.getPersonnelList()
  },

  methods:{
    getPersonnelList() {
      axios.post('api/data/personnelList').then(res => {
        console.log(res)
        if (res.data.code == '200') {
          console.log()
          let dataArr = []
          for (let i = 0; i < res.data.data.length; i++) {
            let item = res.data.data[i]
            let education = item.EDUCATION
            if (/^\d+$/.test(education)) {
              if (education === '1') {
                education = '初中'
              } else if (education === '2') {
                education = '高中'
              } else if (education === '3') {
                education = '中专'
              } else if (education === '4') {
                education = '大专'
              } else if (education === '5') {
                education = '本科'
              } else if (education === '6') {
                education = '研究生'
              } else {
                education = '其他'
              }
            }
            // let s = [item.NAME,item.SEX,"<span  class='colorGrass'>"+ item.EDUCATION +"</span>"]
            let s = [item.NAME,item.SEX,"<span  class='colorGrass'>"+ education +"</span>"]
            dataArr.push(s)
          }
          this.config.data = dataArr
          this.$refs.dvScolBoard.autoResizeMixinInit();
          setTimeout(() => {
            this.getPersonnelList();
          }, 60000)
        }
      }).catch(err => {
        console.log(err);
      })
    }
  }
}
</script>

<style lang="scss" scoped>
$box-height: 300px;
$box-width: 500px;
#centerRight1 {
  padding: 16px;
  padding-top: 20px;
  height: $box-height;
  width: $box-width;
  border-radius: 5px;
  .bg-color-black {
    height: $box-height - 30px;
    border-radius: 10px;
  }
  .text {
    color: #c3cbde;
  }
  .body-box {
    border-radius: 10px;
    overflow: hidden;
    .dv-scr-board {
      width: 500px;
      height: 280px;
    }
  }
}
</style>
